<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/TR/REC-html40" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"><head>



<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 9">
<meta name="Originator" content="Microsoft Word 9">
<link rel="File-List" href="http://online-judge.uva.es/p/v105/g_files/filelist.xml">
<link rel="Edit-Time-Data" href="http://online-judge.uva.es/p/v105/g_files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Problem G - Power et al.</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Shahriar Manzoor</o:Author>
  <o:LastAuthor>Shahriar Manzoor</o:LastAuthor>
  <o:Revision>169</o:Revision>
  <o:TotalTime>1144</o:TotalTime>
  <o:LastPrinted>2002-10-30T12:22:00Z</o:LastPrinted>
  <o:Created>2002-02-22T05:31:00Z</o:Created>
  <o:LastSaved>2003-06-13T02:55:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Company>CSE, BUET</o:Company>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:Version>9.2720</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Print</w:View>
  <w:Zoom>BestFit</w:Zoom>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery>
  <w:UseMarginsForDrawingGridOrigin/>
  <w:Compatibility>
   <w:FootnoteLayoutLikeWW8/>
   <w:ShapeLayoutLikeWW8/>
   <w:AlignTablesRowByRow/>
   <w:ForgetLastTabAlignment/>
   <w:LayoutRawTableWidth/>
   <w:LayoutTableRowsApart/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;}
h1
	{mso-style-next:Normal;
	margin:0in;
	margin-bottom:.0001pt;
	text-align:justify;
	mso-pagination:widow-orphan;
	mso-outline-level:1;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	color:black;
	mso-font-kerning:0pt;
	font-weight:normal;
	font-style:italic;}
h2
	{mso-style-next:Normal;
	margin:0in;
	margin-bottom:.0001pt;
	text-align:justify;
	mso-pagination:widow-orphan;
	mso-outline-level:2;
	tab-stops:143.25pt;
	font-size:18.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	color:black;
	mso-bidi-font-weight:normal;}
p.MsoCaption, li.MsoCaption, div.MsoCaption
	{mso-style-next:Normal;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;
	font-weight:bold;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
p.MsoBodyText2, li.MsoBodyText2, div.MsoBodyText2
	{margin:0in;
	margin-bottom:.0001pt;
	text-align:justify;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:black;
	mso-bidi-font-weight:bold;}
a:link, span.MsoHyperlink
	{color:#6633CC;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
em
	{mso-bidi-font-style:normal;}
pre
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Courier New";}
p.Preformatted, li.Preformatted, div.Preformatted
	{mso-style-name:Preformatted;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:none;
	tab-stops:0in 47.95pt 95.9pt 143.85pt 191.8pt 239.75pt 287.7pt 335.65pt 383.6pt 431.55pt 479.5pt;
	layout-grid-mode:char;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";}
span.StyleArial16pt
	{mso-style-name:"Style Arial 16 pt";
	mso-ansi-font-size:16.0pt;
	mso-ascii-font-family:Arial;
	mso-hansi-font-family:Arial;
	font-weight:bold;}
@page Section1
	{size:595.45pt 841.7pt;
	margin:1.0in 1.0in 1.0in 1.0in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
@list l0
	{mso-list-id:1248344018;
	mso-list-type:hybrid;
	mso-list-template-ids:1482442014 67698711 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
	{mso-level-number-format:alpha-lower;
	mso-level-text:"%1\)";
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head><body style="" lang="EN-US" vlink="purple" link="#6633cc">

<div class="Section1">

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-size: 28pt; font-family: Arial;">Problem G</span></b><span style="font-family: Arial;"><br>
</span><b><span style="font-size: 20pt; font-family: Arial;">Power et al.</span></b><span style="font-family: Arial;"><br>
<b style="">Input: </b><span style="">Standard Input<o:p></o:p></span></span></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-family: Arial;">Output: </span></b><span style="font-family: Arial;">Standard Output<o:p></o:p></span></p>

<p class="MsoBodyText"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoBodyText" style="text-align: justify;">Finding the exponent of any
number can be very troublesome as it grows exponentially <span style="font-family: Wingdings;"><span style="">J</span></span>.
But in this problem you will have to do a very simple task. Given two non-negative
numbers <b style="">m </b>and <b>n</b>, you will
have to find the last digit of <b style="">m</b><b style=""><sup><span style="font-size: 14pt;">n</span></sup></b>
in decimal number system.</p>

<p class="MsoNormal" style="text-align: justify;"><span class="StyleArial16pt"><span style="font-size: 16pt; font-family: Arial;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></span></p>

<p class="MsoNormal" style="text-align: justify;"><span class="StyleArial16pt"><span style="font-size: 16pt; font-family: Arial;">Input<o:p></o:p></span></span></p>

<p class="MsoBodyText" style="text-align: justify;">The input file contains less
than <b style="">100000</b> lines. Each line contains
two integers <b style="">m </b>and <b>n</b> (Less
than <b>10^101</b>). Input is terminated by a line containing two zeroes. This
line should not be processed.</p>

<p class="MsoNormal" style="text-align: justify;"><span class="StyleArial16pt"><span style="font-size: 16pt; font-family: Arial;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></span></p>

<p class="MsoNormal" style="text-align: justify;"><span class="StyleArial16pt"><span style="font-size: 16pt; font-family: Arial;">Output<o:p></o:p></span></span></p>

<p class="MsoBodyText" style="text-align: justify;">For each set of input you must
produce one line of output which contains a single digit. This digit is the
last digit of <b style="">m</b><b style=""><sup><span style="font-size: 14pt;">n</span></sup></b>.</p>

<h1><span style="font-size: 16pt; font-family: Arial;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></h1>

<h1><b><span style="font-size: 16pt; font-family: Arial; font-style: normal;">Sample Input<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>Output for Sample Input<o:p></o:p></span></b></h1>

<table style="border: medium none ; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; border-collapse: collapse;" bgcolor="#cccccc" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr>
  <td style="border: 0.5pt solid windowtext; padding: 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
  <p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 11pt; font-family: &quot;Courier New&quot;;">2 2<o:p></o:p></span></b></p>
  <pre style="text-align: justify;"><b style=""><span style="font-size: 11pt;">2 5<o:p></o:p></span></b></pre><pre style="text-align: justify;"><b style=""><span style="font-size: 11pt;">0 0</span></b><b><span style=""><o:p></o:p></span></b></pre></td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 0.5pt 0.5pt 0.5pt medium; padding: 0in 5.4pt; width: 222.85pt;" valign="top" width="297">
  <p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 11pt; font-family: &quot;Courier New&quot;;">4<o:p></o:p></span></b></p>
  <p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 11pt; font-family: &quot;Courier New&quot;;">2</span><o:p></o:p></b></p>
  <p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><b><span style="font-size: 11pt; font-family: &quot;Courier New&quot;;"><o:p></o:p></span></b></p>
  </td>
 </tr>
</tbody></table>


<div class="MsoNormal" style="text-align: center;" align="center">

<hr align="center" size="2" width="100%">

</div>


<p class="MsoCaption">Problemsetter: Shahriar Manzoor</p>

</div>

</body></html>